
public class e014 {
    public static void main(String[] args) {
	long sTime = System.currentTimeMillis();
	int biggestNum = 0;
        int biggestCycle = 0;
        for (int i = 3; i < 1000000; i++) {
            int n = n(i);
            if (n > biggestCycle) {
                biggestCycle = n;
                biggestNum = i;
            }
        }
        System.out.println(biggestNum);
        long fTime = System.currentTimeMillis();
        System.out.println("Time: " + (fTime - sTime) + "ms");
    }

    static int n(int i) {
        long j = i;
        int loopNum = 1;
        while(j != 1) {
            if(j % 2 == 0) {
                j /= 2;
            } else {
                j = (3 * j) + 1;
            }
            loopNum++;
        }
        return loopNum;
    }
}